<?php


namespace app\api\controller;

use think\facade\Request;
use app\api\model\Logistics as BZModel;

class Logistics extends Common
{
    /**
     * @param BZModel $model
     * @param Request $request
     * @return \think\response\Json
     */
    public function index(BZModel $model, Request $request)
    {
        $res = $model->index($request::param('page', 1), $request::param('size', 10));
        return is_string($res) ? $this->returnJson(500, $res) : $this->returnJson(200, 'ok', $res);
    }

    /**
     * @param BZModel $model
     * @param Request $request
     * @return \think\response\Json
     */
    public function store(BZModel $model, Request $request)
    {
        $data = $request::param();
        $res = $model->store($data);
        return is_string($res) ? $this->returnJson(500, $res) : $this->returnJson(200, 'ok', $res);
    }

    /**
     * @param $id
     * @param BZModel $model
     * @return \think\response\Json
     */
    public function show($id, BZModel $model)
    {
        $res = $model->show($id);
        return is_string($res) ? $this->returnJson(500, $res) : $this->returnJson(200, 'ok', $res);
    }

    /**
     * @param $id
     * @param BZModel $model
     * @param Request $request
     * @return \think\response\Json
     */
    public function update($id, BZModel $model, Request $request)
    {
        $data = $request::param();
        $res = $model->edit($id, $data);
        return is_string($res) ? $this->returnJson(500, $res) : $this->returnJson(200, 'ok', $res);
    }

    /**
     * @param $id
     * @param BZModel $model
     * @return \think\response\Json
     */
    public function delete($id, BZModel $model)
    {
        $res = $model->del($id);
        return is_string($res) ? $this->returnJson(500, $res) : $this->returnJson(200, 'ok', $res);
    }
}
